# 统计加班时间


from openpyxl import Workbook, load_workbook
from datetime import date


def create_data():
    wb = Workbook()
    sh = wb.active

    rows = [
        ['Date', '姓名', '打卡时间'],
        [date(2020, 12, 1), '张三', '18:30'],
        [date(2020, 12, 2), '李四', '19:30'],
        [date(2020, 12, 3), '王五', '20:30'],
        [date(2020, 12, 4), '赵六', '18:50'],
        [date(2020, 12, 5), '田七', '19:30'],
        [date(2020, 12, 6), '吕小布', '21:30']
    ]

    for row in rows:
        sh.append(row)

    wb.save('../case01_file/13_统计加班时间.xlsx')


def statistics():
    # 读取数据
    wb = load_workbook('../02.py_excelFile/13_统计加班时间.xlsx')
    sh = wb.active
    data = []
    for i in range(2, sh.max_row + 1):
        temp_data = []
        for j in range(1, sh.max_columns + 1):
            temp_data.append(sh.cell(i, j).value)

    # 统计

    # 保存

    wb = Workbook()
    sh = wb.active

    rows = [
        ['Date', '姓名', '打卡时间'],
        [date(2020, 12, 1), '张三', '18:30'],
        [date(2020, 12, 2), '李四', '19:30'],
        [date(2020, 12, 3), '王五', '20:30'],
        [date(2020, 12, 4), '赵六', '18:50'],
        [date(2020, 12, 5), '田七', '19:30'],
        [date(2020, 12, 6), '吕小布', '21:30']
    ]

    for row in rows:
        sh.append(row)

    wb.save('../case01_file/13_统计加班时间.xlsx')


if __name__ == '__main__':
    create_data()
